OTListen
Listens for an incoming connection request.C INTERFACE
OSStatus OTListen(EndpointRef ref, TCall* call);C++ INTERFACE
OSStatus TEndpoint::Listen(TCall* call);PARAMETERS
ref
- The endpoint reference of the endpoint listening for the connection request.
call
- A pointer to a
TCall
structure (page 3-62) that contains information about the address of the peer requesting the connection, option information, data associated with the connection request, and the connection ID for this connection.DESCRIPTION
You use theOTListen
function to listen for incoming connection requests. On return, the function fills in theTCall
structure referenced by thecall
parameter with information about the connection request. After retrieving the connection request using theOTListen
function, you can reject the request using theOTSndDisconnect
function, or you can accept the request using theOTAccept
function.If the endpoint is in synchronous mode and is blocking, the
OTListen
function returns when a connection request has arrived. If the endpoint is in asynchronous mode or is not blocking, theOTListen
function returns any pending connection requests or returns thekOTNoDataErr
result if there are
no pending connection requests. You can also call theOTListen
function from within a notifier function in response to theT_LISTEN
event. In this case, the function returns a result immediately.SPECIAL CONSIDERATIONS
Not all endpoints support the sending of data with a connection request. Examine theconnect
field of theTendpointInfo
structure for the endpoint to determine if the endpoint supports the sending of data and to determine the maximum size of the data.To ensure portability, do not explicitly bind the endpoint to which you are passing off a connection if its address is to be the same as that of the endpoint listening for connection requests.
VALID STATES
T_IDLE
,T_INCON
SEE ALSO
You use theOTAccept
function (described next) to read an incoming connection request that you have retrieved using theOTListen
function.You use the
TCall
structure (page 3-62) to store information about the address of the peer requesting the connection, option information, data associated with the connection request, and the connection ID for this connection.You use the
OTSndDisconnect
function (page 3-149) to reject a connection request.You specify the maximum number of outstanding connections for an endpoint when you bind the endpoint using the
OTBind
function (page 3-77).For information on how to use this function with a TCP/IP protocol, see page 8-18 in the TCP/IP chapter.
For information on how to use this function with AppleTalk protocols, see page 13-11 in the ADSP chapter and page 15-10 in the PAP chapter.
You examine the
connect
field of theTEndpointInfo
structure (page 3-48) to determine whether your endpoint supports the sending of data with a connection request.